#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		string s;
		cin >> s;
		int ans = 0;
		if (s.size() == 1)
		{
			if (s[0] == '^') ans = 1;
			else if (s[0] == '_') ans = 2;
		}
		else
		{
			for (int i = 0; i < s.size(); i++)
			{
				if (s[i] == '_')
				{
					if (i == 0)
					{
						s.insert(i, 1, '^');
						ans++;
					}
					else if (i == s.size() - 1)
					{
						s += '^';
						ans++;
					}
					else
					{
						if (s[i - 1] != '^')
						{
							s.insert(i, 1, '^');
							ans++;
						}
						if (s[i + 1] != '^')
						{
							s.insert(i + 1, 1, '^');
							ans++;
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}